home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.4 KB | 176 lines | [TEXT/ToyS] |
- -- Preferences
- property kasPrefName : "Foreign Aliases 1.0"
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasFoldersToDo -- The folders left to process
- global gasTrashed -- Number gone!
- global gasChecked -- Number checked!
-
-
- on open fsObjs
- -- Load prefs, show window
- pfLoad()
-
- set gasTrashed to 0
- set gasChecked to 0
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (extended info for fsObj)
-
- if (invisible status of myInfo) then
- DoOne(fsObj)
- else if (system type of myInfo is "fold") then
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
-
- if (n > 1) then
- set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
- else
- set gasFoldersToDo to {}
- end if
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- pause for 5 with seconds timing -- Let screen wait...
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- pfSave() -- Save window location
- end open
-
-
- on DoOne(fsObj)
- set aFileInfo to (alias info from fsObj)
-
- display info gasInfoWind ¬
- message "File: " & (original name of aFileInfo) ¬
- at line 2
-
- set gasChecked to gasChecked + 1
-
- try
- set myInfo to (extended info for fsObj)
- on error
- TrashFile(fsObj, "Info error.")
- return
- end try
-
- set invisible status of myInfo to false
-
- try
- set the catalog info of fsObj to myInfo
- on error
- beep
- end try
-
- TrashFile(fsObj, "Invisible")
-
- display info gasInfoWind ¬
- message ("Checked: " & gasChecked) ¬
- at line 7 ¬
- using color 15
- end DoOne
-
-
- on TrashFile(fsObj, reason)
- display info gasInfoWind ¬
- message reason at line 3
-
- try
- collate fsObj with the trasher
- on error err
- display info gasInfoWind ¬
- message ("Error: " & err) ¬
- at line 12 ¬
- using color (15 * 1024)
- beep
- end try
-
- set gasTrashed to gasTrashed + 1
-
- display info gasInfoWind ¬
- message ("Trashed: " & gasTrashed) ¬
- at line 8 ¬
- using color (15 * 1024)
- end TrashFile
-
-
- on GoDeep(foldObj)
- display info gasInfoWind ¬
- message "Path: " & (foldObj as string)
-
- set daddy to foldObj as string
-
- -- Do aliases
- display info gasInfoWind ¬
- message "Scanning aliases" at line 5
-
- set myItems to the entries in foldObj ¬
- without whose visibility is
-
- repeat with myItem in myItems
- try
- set oneItem to (daddy & myItem) as alias
- DoOne(oneItem)
- on error err
- display info gasInfoWind ¬
- message ("Error: " & err) ¬
- at line 13 ¬
- using color (15 * 1024)
- beep
- end try
- end repeat
-
- -- Do folders
- display info gasInfoWind ¬
- message "Scanning subfolders" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
- end GoDeep
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- set gasInfoPos to item 1 of ourPrefs
- on error
- set gasInfoPos to {0, 0}
- end try
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos} named kasPrefName
- end pfSave
-